import json,re;
def remove_html(html):
    pattern = re.compile(r'<[^>]+>',re.S)
    result = pattern.sub('', html)
    return result.replace("&nbsp;"," ").replace("\n","")
def replaceCharEntity(htmlstr):
    CHAR_ENTITIES={'nbsp':' ','160':' ',
                   'lt':'<','60':'<',
                   'gt':'>','62':'>',
                   'amp':'&','38':'&',
                   'quot':'"','34':'"',}

    re_charEntity=re.compile(r'&#?(?P<name>w+);')
    sz=re_charEntity.search(htmlstr)
    while sz:
        entity=sz.group()#entity全称，如>
        key=sz.group('name')#去除&;后entity,如>为gt
        try:
            htmlstr=re_charEntity.sub(CHAR_ENTITIES[key],htmlstr,1)
            sz=re_charEntity.search(htmlstr)
        except KeyError:
            #以空串代替
            htmlstr=re_charEntity.sub('',htmlstr,1)
            sz=re_charEntity.search(htmlstr)
    return htmlstr
def repalce(s,re_exp,repl_string):
    return re_exp.sub(repl_string,s)
def getQuestions():
    with open("aa.json") as f:
        return (json.loads(f.readline())["data"]["paperDetail"]["questions"])
for i in getQuestions():
    print(f"\n\n问题：{remove_html(i['description'])}")
    # print(i["options"])
    print(f"答案：{remove_html([x['description'] for x in i['options'] if x['label'] == i['solution']][0])}")
    for j in [x['description'] for x in i['options'] if x['label'] != i['solution']]:
        print(f"###{remove_html(j)}")